<!-- 参考:https://codepen.io/Hyperplexed/pen/QWQRGdO-->
<template>
  <div class="card">
    <div class="card-content" :onmouseover="() => data.isTitleShow = false" :onmouseout="() => data.isTitleShow = true">
      <!-- <h3 class="card-title">关于作者</h3> -->
      <h4 class="card-subtitle"></h4>
    </div>
    <i class="fa-solid fa-hat-witch card-icon" :onmouseover="() => data.isTitleShow = false"
      :onmouseout="() => data.isTitleShow = true" v-show="data.isTitleShow">AboutThisWork</i>
  </div>

</template>

<script setup>
import { onMounted, reactive } from 'vue'
const data = reactive({
  isTitleShow: true
});
//对于页面元素的操作，要在元素生成后
onMounted(() => {
  const subtitle = document.getElementsByClassName("card-subtitle")[0];
  const createWord = (text, index) => {
    const word = document.createElement("a");
    word.innerHTML = `${text} `;
    word.classList.add("card-subtitle-word");
    word.style.transitionDelay = `${index * 40}ms`;
    return word;
  }

  const addWord = (text, index) => subtitle.appendChild(createWord(text, index));
  const createSubtitle = text => text.split(" ").map(addWord);
  createSubtitle("Author：Field/SoloShine SourceCode：https://gitee.com/fieldtianye/wallpaper-test-vue3 Email：tianyeote@gamil.com");

})

</script>

<style>
:root {
  --border: rgb(17, 21, 23);

  --g1: rgba(98, 0, 234, 0.587);
  --g2: rgba(87, 64, 236, 0.393);
  --g3: rgba(253, 216, 53, 0.377);
}

/* body {
  background-color: rgb(10, 10, 10);
  display: grid;
  height: 100vh;
  margin: 0px;
  padding: 0px;
  place-items: center;
} */

.card {
  height: 170px;
  aspect-ratio: 1 / 1.6;
  /* border: 0.5vmin solid var(--border); */
  cursor: pointer;
  position: relative;
  width: 600px;
  background-color: #0000001F;
}

.card:hover:before {
  background-position: 100% 100%;
  transform: scale(1.08, 1.03);
}

.card:hover>.card-content {
  background-position: -10% 0%;
}

.card:hover>.card-icon {
  color: white;
}

.card:hover>.card-content>.card-subtitle>.card-subtitle-word {
  opacity: 1;
  transform: translateY(0%);
  transition: opacity 0ms, transform 200ms cubic-bezier(.90, .06, .15, .90);
}

.card:before {
  background: linear-gradient(130deg,
      transparent 0% 33%,
      var(--g1) 66%,
      var(--g2) 83.5%,
      var(--g3) 100%);
  background-position: 0% 0%;
  background-size: 300% 300%;
  content: "";
  height: 100%;
  left: 0px;
  pointer-events: none;
  position: absolute;
  top: 0px;
  transition: background-position 350ms ease, transform 350ms ease;
  width: 100%;
  z-index: 1;
}

.card-content {
  background-image: radial-gradient(rgba(255, 255, 255, 0.2) 8%,
      transparent 8%);
  background-position: 0% 0%;
  background-size: 5vmin 5vmin;
  height: calc(100% - 10vmin);
  /* padding: 5vmin; */
  position: relative;
  transition: background-position 350ms ease;
  width: calc(100% - 10vmin);
  z-index: 2;
}

.card-title,
.card-subtitle {
  color: white;
  font-family: "Anek Latin", sans-serif;
  font-weight: 800;
  margin: 0px;
  text-align: left;
}

.card-title {
  font-size: 6vmin;
}

.card-subtitle {
  font-size: 2vmin;
  margin-top: 2vmin;
}

.card-subtitle-word {
  display: inline-block;
  margin: 0vmin 0.3vmin;
  opacity: 0;
  position: relative;
  transform: translateY(40%);
  transition: none;
}

.card-icon {
  bottom: 0px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 7vmin;
  left: 0px;
  margin: 5vmin;
  position: absolute;
  transition: color 250ms ease;
  z-index: 2;
}

.meta-link {
  align-items: center;
  backdrop-filter: blur(3px);
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  display: inline-flex;
  gap: 5px;
  left: 10px;
  padding: 10px 20px;
  position: fixed;
  text-decoration: none;
  transition: background-color 350ms, border-color 350ms;
  z-index: 10000;
}

.meta-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.meta-link>i,
.meta-link>span {
  height: 20px;
  line-height: 20px;
}

.meta-link>span {
  color: white;
  font-family: "Anek Latin", sans-serif;
  transition: color 600ms;
}
</style>